<?php

include("database.php");

session_start();
if (empty($_SESSION['facebookid'])){ ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>SMS Notification System</title>
    </head>
    
    <body>
    
        <div id="content" style="text-align:center;height:100px;padding-top:40px;">
        
        	<a href="login.php"><img src="login.png" /></a>
        
        </div>
    
    </body>
    </html>
<?php
	exit();
}

$firstTime = false;

$result = mysql_query("SELECT * FROM users WHERE facebookid='" . $_SESSION['facebookid'] . "' LIMIT 1");
if (mysql_num_rows($result) == 0){
	$firstTime = true;
	if (!strstr($_SERVER['SCRIPT_NAME'], "profile.php")){
		header("Location: /profile.php");
		exit();
	}
}
else{
	$profileData = mysql_fetch_assoc($result);
	$company = $profileData["company"];
	$timezone = $profileData["timezone"];
	$username = $profileData["username"];
	$format = $profileData["format"];
	$emailaddress = $profileData["emailaddress"];
	
	include("globalvars.php");
	
	date_default_timezone_set($zonelist[$timezone]);
}

?>